﻿#ifndef APPMONITORLOGWIDGET_H
#define APPMONITORLOGWIDGET_H

#include <QDialog>
#include "common.h"
#include "Logger.h"
#include "appmonitorlog.h"
#include "dbservice.h"

#define MAX_DISPLAYED_LOGS_COUNT 1000



typedef enum
{
    TIME_QUERY_MODE_UNLIMIT,
    TIME_QUERY_MODE_TODAY,
    TIME_QUERY_MODE_LAST_3DAYS,
    TIME_QUERY_MODE_LAST_7DAYS,
    TIME_QUERY_MODE_LAST_30DAYS,
    TIME_QUERY_MODE_LAST_SELECT
}TIME_QUERY_MODE;

typedef enum
{
    LOG_STATE_QUERY_MODE_UNLIMIT,
    LOG_STATE_QUERY_MODE_SUCCESSFUL,
    LOG_STATE_QUERY_MODE_FAILED
}LOG_STATE_QUERY_MODE;

namespace Ui {
class AppMonitorLogWidget;
}

class AppMonitorLogWidget : public QDialog
{
    Q_OBJECT

public:
    explicit AppMonitorLogWidget(QWidget *parent = 0);
    ~AppMonitorLogWidget();


    void displayLogs();

    void initMonitorNameCombox();

    void initLogStateCombox();

private slots:
   void reloadWithQueryConditions();

   void onPrePageClicked();

   void onNextPageClicked();

   void onFirstPageClicked();

   void onLastPageClicked();

   void onQueryTimeChanged(int index);

   void onDeleteLogButtonCliecked();

private:
   void getQueryConditionsFromUI(QString* & queryMonitorName, QString* & startTime, QString* & endTime, QString* & logState);

private:
    Ui::AppMonitorLogWidget *ui;

    list<AppMonitorLog *> logs;

    int currentPageNum = 1;

    int pageSize = 20;

};

#endif // APPMONITORLOGWIDGET_H
